package edu.hunau.pojo;

import java.util.Objects;

/**
 *  课程
 */
public class Course {
    //课程编号
    private String id;
    //课程名称
    private String name;
    //课程性质
    private CourseType type;

    //学分
    private double creadit;


    public Course(){

    }

    public Course(String id, String name, CourseType type, double creadit) {
        //todo: 完成构造器
        this.id=id;
        this.name=name;
        this.type=type;
        this.creadit=creadit;

    }


    //TODO 1: 重写 equals、hashCode、toString方法


    @Override
    public boolean equals(Object o) {
        if (o == null || getClass() != o.getClass()) return false;
        Course course = (Course) o;
        return Double.compare(creadit, course.creadit) == 0 && Objects.equals(id, course.id) && Objects.equals(name, course.name) && type == course.type;
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, type, creadit);
    }

    @Override
    public String toString() {
        return "Course{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", type=" + type +
                ", creadit=" + creadit +
                '}';
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public CourseType getType() {
        return type;
    }

    public void setType(CourseType type) {
        this.type = type;
    }

    public double getCreadit() {
        return creadit;
    }

    public void setCreadit(double creadit) {
        this.creadit = creadit;
    }
}
